/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.app.controller;

import com.app.entity.Producto;
import com.app.sessionBeans.ProductoFacade;
import java.util.List;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
import org.primefaces.event.FlowEvent;

/**
 *
 * @author EduardoAlexis
 */
@Named(value = "productoController")
@RequestScoped
public class ProductoController {
    @EJB
    private ProductoFacade productoFacade;
    /**
     * Creates a new instance of ProductoController
     */
    
    private Producto selected;
    private List <Producto> items = null;
     private boolean skip;

    public ProductoFacade getProductoFacade() {
        return productoFacade;
    }
    
    public ProductoController() {
    }

    public Producto getSelected() {
        return selected;
    }
    public void setSelected(Producto selected) {
        this.selected = selected;
    }
    public List<Producto> getItems() {
        if (items==null){
    items=getProductoFacade().findAll();
        }
        return items;
    }
    
    //--- wizard    
    public boolean isSkip() {
        return skip;
    }
 
     
    public void setSkip(boolean skip) {
        this.skip = skip;
    }
    
    
     public String onFlowProcess(FlowEvent event) {
        if(skip) {
            skip = false;   //reset in case user goes back
            return "confirm";
        }
        else {
            return event.getNewStep();
           
        }
    }
    
    
    
    
    
  public String listarProductos() {

        
        return "productos";
    }
    public String crearProducto() {

        
        return "crearproducto";
    }
  
   
}
